import { Injectable } from '@angular/core';

import { HttpClient,HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { ViewData } from './faucet';
import { FormGroup } from '@angular/forms';





@Injectable({
  providedIn: 'root'
})



export class FaucetService {

  constructor(private http: HttpClient) { }

 

  getFaucet():Observable<ViewData[]> {
    return this.http.get<ViewData[]>('/api')
  }



  getParamsFaucet(params:FormGroup){
    const param =new HttpParams({ fromObject: params.value});
    return this.http.get<ViewData[]>('/api/queryParams',{params:param})
  }


  getByIdFucet(id:number){
    return this.http.get<ViewData[]>(`/api/details/${id}`)
  }

  getCharts(id:number){
    return this.http.get<any[]>(`/api/chart/${id}`)
  }
} 

